/*
	@file: log/include/logger/FileLogger.h
	@author: Wolfhead
 */
#ifndef _LOG_FILE_LOGGER_H_
#define _LOG_FILE_LOGGER_H_

#include <boost/thread.hpp>
#include "Logger.h"

namespace logger
{

class FileLogger
	: public Logger
{
public:
	FileLogger(const std::string& path);

	int set_interval(const std::string& interval);

	int set_interval(time_t interval);

	int log(const std::string& message);

	int log(const std::vector<std::string>& message_vec);

    int flush();

private:

	int parse_interval(const std::string& interval, long& seconds);

	int refresh_file(bool force_refresh = false);

	int open_file();

	boost::mutex m_mutex;

	std::string m_path;

	time_t m_interval;
	time_t m_file_time;

	boost::shared_ptr<FILE> m_file;
};

}

#endif //#ifndef _LOG_FILE_LOGGER_H_
